﻿@model NewLife.Cube.Charts.ECharts
@using NewLife;
@using NewLife.Web;
@using NewLife.Cube;
@using XCode;
@{
    var chart = Model;
    var name = chart.Name;
    var chartName = "chart_" + name;
    var optionName = "option_" + name;

    var style = chart.Style;
    if (chart.Width > 0)
    {
        style += String.Format("width: {0}px;", chart.Width);
    }
    else if (chart.Width < 0)
    {
        style += String.Format("width: {0}%;", -chart.Width);
    }

    if (chart.Height > 0)
    {
        style += String.Format("height: {0}px;", chart.Height);
    }
    else if (chart.Height < 0)
    {
        style += String.Format("height: {0}%;", -chart.Height);
    }
}
<div id="@name" style="@style" class="@chart.Class"></div>
<script type="text/javascript">
    var @chartName = echarts.init(document.getElementById('@name'));
    var @optionName = @Html.Raw(chart.Build());
    @(chartName).setOption(@optionName);
</script>